/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * fenetre4.java
 *
 * Created on 5 janv. 2012, 17:58:22
 */
package bdlocale;

/**
 *
 * @author Marouane
 */
/*import java.net.*;
import javax.media.*;*/
import java.text.*;
import java.io.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.media.*;
import javax.swing.*;
import java.sql.*;
import java.util.*;
/*import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.data.JRCsvDataSource;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.util.JRLoader;
import net.sf.jasperreports.engine.xml.JRXmlLoader;
import net.sf.jasperreports.view.JasperViewer;*/
public class fenetre4 extends javax.swing.JFrame {
     int clic = 0;
     String tempchaine = "";
     int champs3 = 0;
    /** Creates new form fenetre4 */
    public fenetre4() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jc1 = new javax.swing.JComboBox();
        jc2 = new javax.swing.JComboBox();
        t3 = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jLabel7 = new javax.swing.JLabel();
        jTextField4 = new javax.swing.JTextField();
        jButton6 = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        t1 = new javax.swing.JTextField();
        t2 = new javax.swing.JTextField();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jb1 = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem3 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem4 = new javax.swing.JMenuItem();
        jMenuItem5 = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        jMenuItem6 = new javax.swing.JMenuItem();
        jMenuItem7 = new javax.swing.JMenuItem();
        jMenuItem8 = new javax.swing.JMenuItem();
        jMenuItem9 = new javax.swing.JMenuItem();
        jMenu4 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setBounds(new java.awt.Rectangle(0, 0, 1000, 1000));
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
            public void windowActivated(java.awt.event.WindowEvent evt) {
                formWindowActivated(evt);
            }
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        jPanel1.setBackground(new java.awt.Color(51, 255, 255));

        jLabel1.setText("Menu des évènements");

        jc2.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jc2ItemStateChanged(evt);
            }
        });

        t3.setEditable(false);

        jLabel2.setText("Evenement");

        jLabel3.setText("Num joueur");

        jLabel4.setText("Nom joueur");

        jButton1.setText("Precision");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText("Enregistrer tout");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton3.setText("Annuler");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jLabel7.setText("Compteur des évènements");

        jButton6.setText("Exporter");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(66, 66, 66)
                .addComponent(jLabel1)
                .addContainerGap(94, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2)
                            .addComponent(jLabel3)
                            .addComponent(jLabel4)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(26, 26, 26)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButton3)
                            .addComponent(jButton1))))
                .addGap(27, 27, 27)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton6, javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE)
                    .addComponent(t3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE)
                    .addComponent(jc1, javax.swing.GroupLayout.Alignment.TRAILING, 0, 109, Short.MAX_VALUE)
                    .addComponent(jc2, javax.swing.GroupLayout.Alignment.TRAILING, 0, 109, Short.MAX_VALUE)
                    .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(31, 31, 31))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel7)
                .addGap(18, 18, 18)
                .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(71, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addComponent(jLabel1)
                .addGap(38, 38, 38)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jc1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jc2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(t3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton2)
                    .addComponent(jButton1))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton3)
                    .addComponent(jButton6))
                .addGap(38, 38, 38)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(53, Short.MAX_VALUE))
        );

        jPanel2.setBackground(new java.awt.Color(153, 153, 153));

        jPanel3.setBackground(new java.awt.Color(204, 204, 204));

        jLabel5.setText("DebutE");

        jLabel6.setText("FinE");

        t1.setEditable(false);
        t1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                t1ActionPerformed(evt);
            }
        });

        t2.setEditable(false);

        jButton4.setText("Annuler");
        jButton4.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton4MouseClicked(evt);
            }
        });

        jButton5.setText("Annuler");
        jButton5.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton5MouseClicked(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel5)
                    .addComponent(jLabel6))
                .addGap(37, 37, 37)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(t1)
                    .addComponent(t2, javax.swing.GroupLayout.DEFAULT_SIZE, 20, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton4)
                    .addComponent(jButton5))
                .addContainerGap(24, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(t1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(t2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton5))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(1079, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap(427, Short.MAX_VALUE)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        jb1.setText("Annoter");
        jb1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jb1MouseClicked(evt);
            }
        });
        jb1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb1ActionPerformed(evt);
            }
        });

        jMenu1.setText("Projet");
        jMenu1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenu1ActionPerformed(evt);
            }
        });

        jMenuItem2.setText("Nouveau Projet");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem2);

        jMenuItem1.setText("Modifier Projet");
        jMenu1.add(jMenuItem1);

        jMenuItem3.setText("Quitter");
        jMenu1.add(jMenuItem3);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Consulter");

        jMenuItem4.setText("Consultation privée");
        jMenu2.add(jMenuItem4);

        jMenuItem5.setText("Consultation générale");
        jMenu2.add(jMenuItem5);

        jMenuBar1.add(jMenu2);

        jMenu3.setText("Paramétrage événement");

        jMenuItem6.setText("Ajouter évènement");
        jMenu3.add(jMenuItem6);

        jMenuItem7.setText("Modifier évènement");
        jMenu3.add(jMenuItem7);

        jMenuItem8.setText("Supprimer évènement");
        jMenu3.add(jMenuItem8);

        jMenuItem9.setText("Liste évènement");
        jMenu3.add(jMenuItem9);

        jMenuBar1.add(jMenu3);

        jMenu4.setText("Aide!");
        jMenuBar1.add(jMenu4);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jb1, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(1210, Short.MAX_VALUE))
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(34, 34, 34)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jb1)
                        .addGap(1540, 1540, 1540))))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        /*  p.dispose();
          p.show();
          p.setBounds(100, 100, 500, 300);*/
}//GEN-LAST:event_jMenuItem2ActionPerformed

private void jMenu1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenu1ActionPerformed
          
}//GEN-LAST:event_jMenu1ActionPerformed

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jButton1ActionPerformed

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jButton3ActionPerformed

private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
    this.setResizable(false);
    new fenetre4().setBounds(600, 500, 500,500);
   jPanel3.setVisible(false);
    try {
            
          Connection c = BDlocale.createConnection();
          Statement st = c.createStatement();
          ResultSet rs = st.executeQuery("select nom_evenement from evenementnonanalyse group by nom_evenement");
          
             while (rs.next()) {
             
                jc1.addItem(rs.getString("nom_evenement"));
	       }
          ResultSet rs1 = st.executeQuery("select num_joueur from joueur");
          
             while (rs1.next()) {
             
                jc2.addItem(rs1.getString("num_joueur"));
	       }
             
             
            
        } catch (Exception ex) {
            ex.printStackTrace();        }
  

}//GEN-LAST:event_formWindowOpened

private void jb1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb1ActionPerformed
/*  
   jPanel3.setVisible(true);
  // Time g =  SimplePalyer.player.getMediaTime();
  // long d = SimplePalyer.player.getMediaNanoseconds();
   int clic = 0;
   clic++;
   
   System.out.println("nombre de clic "+clic);
   Time temps =  SimplePalyer.player.getMediaTime();
   Double vv = temps.getSeconds();
   Double seconde = vv%60;
   int minute = (int) ((vv/60)%60);
   int heure = (int) (vv/(60*60));
   String tempchaine = heure+":"+minute+":"+seconde;
   t1.setText(""+tempchaine+"\r");
   
   
   */
   
   
    
  
    

//   fenetre3.simpleplayer.


}//GEN-LAST:event_jb1ActionPerformed

private void jb1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jb1MouseClicked
  jPanel3.setVisible(true);
  clic++;
   String minute1 = "",minute2 = "",seconde1 = "",seconde2 = "";
   javax.media.Time temps =  SimplePalyer.player.getMediaTime();
   
   Double vv = temps.getSeconds();
        
        long seconde = Math.round(vv%60);
        NumberFormat formatter = new DecimalFormat("00");
        
     
        
  // int secondeentier = Integer.parseInt(seconde.toString());
   int minute = (int) ((vv/60)%60);
   
   int heure = (int) (vv/(60*60));
      String minutee = formatter.format(minute);
      String heuree = formatter.format(heure);
   tempchaine = heuree+":"+minutee+","+seconde;
  /* if(minute < 10 && seconde < 10)
       
   tempchaine = 0+heure+":"+0+minute+","+0+seconde;
   
   else if (minute < 10)
          tempchaine = 0+heure+":"+0+minute+","+seconde;

   
   
   else if(((long)(seconde)) < 10)
       
                 tempchaine = 0+heure+":"+minute+","+0+seconde;
   else 
                        tempchaine = 0+heure+":"+minute+","+seconde;*/

       
   if(clic == 1 || clic == 0){
   t1.setText(""+tempchaine);
   //System.out.print("le teste est "+t1.getText());
   /* seconde1 = tempchaine.substring(4,6);
    minute1 =  tempchaine.substring(1,3);*/
   }
   
   else {
        t2.setText(""+tempchaine);
         /*seconde2 = tempchaine.substring(4,6);
         minute2 =  tempchaine.substring(1,3);*/
   }
  /* if(Integer.parseInt(minute1) > Integer.parseInt(minute2)){
      
       JOptionPane.showMessageDialog(null,"veuillez rénitialisez le boutton du haut");
         
   }*/
   
   
  
}//GEN-LAST:event_jb1MouseClicked

private void jButton4MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton4MouseClicked
  clic = 0;
  t1.setText("");
  
}//GEN-LAST:event_jButton4MouseClicked

private void jButton5MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton5MouseClicked
  t2.setText("");
}//GEN-LAST:event_jButton5MouseClicked

private void t1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_t1ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_t1ActionPerformed

private void jc2ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jc2ItemStateChanged
 try {
            
          Connection c = BDlocale.createConnection();
          Statement st = c.createStatement();
          ResultSet rs = st.executeQuery("select nom_joueur from joueur where num_joueur = "+Integer.parseInt(jc2.getSelectedItem().toString())+"");
          
             while (rs.next()) {
              t3.setText(""+rs.getInt("nom_joueur"));
              champs3 = Integer.parseInt(t3.getText());
	       }     
            
        } catch (Exception ex) {
            ex.printStackTrace();        } 
}//GEN-LAST:event_jc2ItemStateChanged

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    
    try {
           
          Connection c = BDlocale.createConnection();
          Statement st = c.createStatement();
          ResultSet rs = st.executeQuery("select Min(Time) from source ");
          String t0 = "";
          
            while (rs.next()) {
              t0 = rs.getString(1);
            //  System.out.println("les teste est : "+rs.getString(1));
             }
         //Pour le t1   
        
          String temps1 = t1.getText();
          String seconde = t0.substring(6,7);
          String seconde1 = temps1.substring(6,7);
          //System.out.println("les secondes est "+seconde);
          String heure = t0.substring(0,2);
          String heure1 = temps1.substring(0,2);
         // System.out.println("la resultat est "+heure);
          String minute = t0.substring(3,5);
          String minute1 = temps1.substring(3,5);
          int t = Integer.parseInt(minute.toString());
          int tt = Integer.parseInt(minute1.toString());
          int yy = t+tt;
          int sec = Integer.parseInt(seconde.toString());
          int sec1 = Integer.parseInt(seconde1.toString());
          int secsec = sec+sec1;

       /*   String resultat = temps1.replaceAll(heure1,heure);
          String resultat1 =  temps1.replaceAll(minute1,Integer.toString(yy));
          String resultat2 =  temps1.replaceAll(seconde1,Integer.toString(secsec));*/
          
               
       /*   System.out.println("les resultat finalfinalfinal "+resultat);
            System.out.println("les resultat finalfinalfinal "+resultat1);
            System.out.println("les resultat finalfinalfinal "+resultat2);*/
           //System.out.println("la somme est "+secsec);
           temps1 = heure+":"+Integer.toString(yy)+","+Integer.toString(secsec);
          // System.out.println("les resultat finalfinalfinal "+temps1);  
      
        //Pour le t2
           
          String temps2 = t2.getText();
          String seconde2 = temps2.substring(6,7);
         // System.out.println("les secondes est "+seconde);
          String heure2 = temps2.substring(0,2);
          //System.out.println("la resultat est "+heure);
          String minute2 = temps2.substring(3,5);
          int tt2 = Integer.parseInt(minute2.toString());
          int yy2 = t+tt2;
          int sec2 = Integer.parseInt(seconde2.toString());
          int secsec2 = sec+sec2;
           temps2 = heure+":"+Integer.toString(yy2)+","+Integer.toString(secsec2);
           //System.out.println("les resultat 2222222 "+temps2);  
         
           Statement stt = c.createStatement();
           Statement sttt = c.createStatement();
           Statement stttt = c.createStatement();
           Statement sttttt = c.createStatement();
           ResultSet rs1 = stt.executeQuery("select Latitude,Longitude,accX,accY,accZ from source where time between '"+temps1+"' and '"+temps2+"' ");
           
         /* String s1 = "placage";
          String s2 = "contact";
          String s3 = "run";*/
          
         ResultSet rs2 = stttt.executeQuery("select num_evenement from evenementnonanalyse where nom_evenement = '"+jc1.getSelectedItem().toString()+"'");
         int numetranger = 0;
         while(rs2.next()){
             numetranger = rs2.getInt("num_evenement");
         }
         
         ResultSet rs3 = sttttt.executeQuery("select max(num) from evenement");
          int  compt = 0;
         while(rs3.next()){
        compt  = rs3.getInt(1);
         }
         
     
          compt++; 
         
         
          while (rs1.next()) {
              
           //System.out.println("Les lignes sont "+rs1.getDouble(1)+" "+rs1.getDouble(2)+" "+rs1.getInt(3)+"\n");
          
              // num1 = 1;
              java.util.Date maDate = new java.util.Date();
              DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
              String datecourante =  dateFormat.format(maDate);
            
              sttt.executeUpdate("insert into evenement (latitude,longitude,AccX,AccY,AccZ,num,num_joueur,numevenementnonanalyse,Datecourante) values("+rs1.getDouble(1)+","+rs1.getDouble(2)+","+rs1.getInt(3)+","+rs1.getInt(4)+","+rs1.getInt(5)+","+compt+","+champs3+","+numetranger+",'"+datecourante+"')");   
             t1.setText("");
             t2.setText("");
             
              // num1++;
               /*ArrayList<Placage>  placage = new ArrayList();
               Placage p1 = new Placage(rs1.getDouble(1),rs1.getDouble(2), rs1.getInt(3),rs1.getInt(4),rs1.getInt(5));
               placage.add(p1);*/
           
           
           
     
               // num2 = 1;
              // sttt.executeUpdate("insert into evenement (nom_evenement,latitude,longitude,AccX,AccY,AccZ,num,num_joueur) values('"+jc1.getSelectedItem().toString() +"',"+rs1.getDouble(1)+","+rs1.getDouble(2)+","+rs1.getInt(3)+","+rs1.getInt(4)+","+rs1.getInt(5)+","+num2+","+champs3+")");   
               // num2++;
             /*  ArrayList<Contact>  acceleration = new ArrayList();
               Contact c1 = new Contact(rs1.getDouble(1),rs1.getDouble(2), rs1.getInt(3),rs1.getInt(4),rs1.getInt(5));
               acceleration.add(c1);*/
            
           
          
             //  num3 = 1;
              // sttt.executeUpdate("insert into evenement (nom_evenement,latitude,longitude,AccX,AccY,AccZ,num,num_joueur) values('"+jc1.getSelectedItem().toString() +"',"+rs1.getDouble(1)+","+rs1.getDouble(2)+","+rs1.getInt(3)+","+rs1.getInt(4)+","+rs1.getInt(5)+","+num3+","+champs3+")");   
              // num3++;
              /* ArrayList<Run>  run = new ArrayList();
               Run r1 = new Run(rs1.getDouble(1),rs1.getDouble(2), rs1.getInt(3),rs1.getInt(4),rs1.getInt(5));
               run.add(r1);*/
           
           
           
             //  num4 = 1;               
              // sttt.executeUpdate("insert into evenement (nom_evenement,latitude,longitude,AccX,AccY,AccZ,num,num_joueur) values('"+jc1.getSelectedItem().toString() +"',"+rs1.getDouble(1)+","+rs1.getDouble(2)+","+rs1.getInt(3)+","+rs1.getInt(4)+","+rs1.getInt(5)+","+num4+","+champs3+")");   
              // num4++;
              /* ArrayList<Regroupement>  regroupement = new ArrayList(); 
               Regroupement reg1 = new Regroupement(rs1.getDouble(1),rs1.getDouble(2), rs1.getInt(3),rs1.getInt(4),rs1.getInt(5));
               regroupement.add(reg1);*/
            
           
            
            } 
                   // JOptionPane.showMessageDialog(null,"Ajout avec succès");

          
         /*   JasperDesign jasperDesign = JRXmlLoader.load("c:\\travauxireport\\statistique4.jrxml");
            JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);

            Map parameters = new HashMap();
          
            JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, c);
            // JasperExportManager.exportReportToPdfFile(jasperPrint, "D:\\impression\\les etas\\var.jrxml");
            JasperViewer.viewReport(jasperPrint, false);*/
           
        
            
    
           
           
        

            
           

            
          /*String secondeee = temps1.substring(8,10);
         System.out.println(Integer.parseInt(minute)+Integer.parseInt(minute1));*/
         
          //System.out.println("la somme est "+);
          //String minute = temps1.substring(3,4);
         // String resultat = temps1.replaceAll(temps1.substring(0,2),heure);
          //System.out.println("le final est "+resultat);
          
         // System.out.println("le temps est "+heure);
         /* String temps2 = t2.getText();
          String resultat2 = temps2.replaceAll(temps2.substring(0,2),heure);*/

          //System.out.println("le t2 est "+temps2);
          
         
         
   
         
          
   
            
            
             
	            
            
        } catch (Exception ex) {
            ex.printStackTrace();        } 
}//GEN-LAST:event_jButton2ActionPerformed

private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
/*        try {
            Connection c = Main.connect();
            Statement s = c.createStatement();
            PrintStream nn =new PrintStream(new FileOutputStream("C:/Users/Marouane/Desktop/essai.csv"));
            ResultSet rs = s.executeQuery("select evenement.Datecourante,evenementnonanalyse.nom_evenement,evenement.latitude,evenement.longitude,evenement.AccX,evenement.AccY,evenement.AccZ,evenement.num,evenement.num_joueur from evenement,evenementnonanalyse where evenementnonanalyse.num_evenement = evenement.numevenementnonanalyse group by evenement.num");
            ResultSetMetaData rsm = rs.getMetaData();
            String noe = rsm.getColumnName(1);
            String nol = rsm.getColumnName(2);
            String nolo = rsm.getColumnName(3);
            String accx = rsm.getColumnName(4);
            String accy = rsm.getColumnName(5);
            String accz = rsm.getColumnName(6);
            String num = rsm.getColumnName(7);
            String num_joueur = rsm.getColumnName(8);
            
            
              
            //ResultSetMetaData rsm = rs.getMetaData();
          
              /* String s1 = rsm.getColumnName(1);
               String s2 = rsm.getColumnName(2);*/
        //  int y = 0;
        /*    int y = 0;
            while(rs.next()){
            
//on écrit les lignes :
            //while(rs.first()){
       /*     nn.print("début évènement");     
            nn.println(noe+" "+rs.getString(1)); 
            nn.println(nol+" "+rs.getDouble(2));
            nn.println(nolo+" "+rs.getDouble(3));
            nn.println(accx+" "+rs.getInt(4));
            nn.println(accy+" "+rs.getInt(5));
            y = rs.getInt(6);
            nn.println(accz+" "+y);
            nn.println(num+" "+rs.getInt(7));
            nn.println(num_joueur+" "+rs.getInt(8));
            //}
            nn.println("fin évènement"); 
            
             }
           
          
           nn.flush(); 
           nn.close(); 
           nn = null; 
*/
            /*JasperDesign jasperDesign = JRXmlLoader.load("c:\\travauxireport\\essai.jrxml");
            JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
 
            Map parameters = new HashMap();
          
            JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, c);
            // JasperExportManager.exportReportToPdfFile(jasperPrint, "D:\\impression\\les etas\\var.jrxml");
            JasperViewer.viewReport(jasperPrint, false);*/
            
            //String[] columnNames = new String[]{s1,s2};
           // JRCsvDataSource ds = new JRCsvDataSource(File.createTempFile(s2, s2));
            
            /*ds.setRecordDelimiter("\r\n");
            ds.setColumnNames(columnNames);*/
      /*  } catch (Exception ex) {
            Logger.getLogger(fenetre4.class.getName()).log(Level.SEVERE, null, ex);
        }
           */
    try {
            Connection c = BDlocale.createConnection();
            Statement s = c.createStatement();
            Statement ss = c.createStatement();

           PrintStream nn =new PrintStream(new FileOutputStream("C:/Users/Marouane/Desktop/test.csv"));
           ResultSet rs2 = ss.executeQuery("select num from evenement group by num");
           int numero = 0;
           while(rs2.next()){
            numero = rs2.getInt(1); 
            ResultSet rs = s.executeQuery("select evenement.Datecourante,evenementnonanalyse.nom_evenement,evenement.latitude,evenement.longitude,evenement.AccX,evenement.AccY,evenement.AccZ,evenement.num,evenement.num_joueur from evenement,evenementnonanalyse where evenementnonanalyse.num_evenement = evenement.numevenementnonanalyse and evenement.num = "+numero+"");
            ResultSetMetaData rsm = rs.getMetaData();
            String temps = rsm.getColumnName(1);
            String noevent = rsm.getColumnName(2);
            String lati = rsm.getColumnName(3);
            String longi = rsm.getColumnName(4);
            String accx = rsm.getColumnName(5);
            String accy = rsm.getColumnName(6);
            String accz = rsm.getColumnName(7);
            String num = rsm.getColumnName(8);
            String num_joueur = rsm.getColumnName(9);
            
            nn.println("début évènement"); 
            while(rs.next()){
            
            nn.println(temps+" "+rs.getString(1)); 
            nn.println(noevent+" "+rs.getString(2));
            nn.println(lati+" "+rs.getDouble(3));
            
            nn.println(longi+" "+rs.getDouble(4));
            nn.println(accx+" "+rs.getInt(5));
            nn.println(accy+" "+rs.getInt(6));
            nn.println(accz+" "+rs.getInt(7));
            nn.println(num+" "+rs.getInt(8));
            nn.println(num_joueur+" "+rs.getInt(9));
            //}
           
            
             }
            nn.println("fin évènement"); 
          
           
           }
             
           nn.flush(); 
           nn.close(); 
           nn = null;
         
                         JOptionPane.showMessageDialog(null,"Export de données avec succès, le chemin du fichier est: C:\\Users\\Marouane\\Desktop\\test.csv");

           
        } catch (Exception ex) {
            ex.printStackTrace();
        }
}//GEN-LAST:event_jButton6ActionPerformed

private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing

 
 
}//GEN-LAST:event_formWindowClosing

private void formWindowActivated(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowActivated
// TODO add your handling code here:
}//GEN-LAST:event_formWindowActivated

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(fenetre4.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(fenetre4.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(fenetre4.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(fenetre4.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new fenetre4().setVisible(true);
                
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JMenuItem jMenuItem6;
    private javax.swing.JMenuItem jMenuItem7;
    private javax.swing.JMenuItem jMenuItem8;
    private javax.swing.JMenuItem jMenuItem9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JButton jb1;
    private javax.swing.JComboBox jc1;
    private javax.swing.JComboBox jc2;
    private javax.swing.JTextField t1;
    private javax.swing.JTextField t2;
    private javax.swing.JTextField t3;
    // End of variables declaration//GEN-END:variables
}
